<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <button @click="msg ='你坏'">修改msg</button>
      <p>{{ msg }}</p>
      <button @click="obj.name = 'rose'">修改对象 - 改name</button>
      <button @click="obj = { name: 'rose', age: 15}">修改对象 - 改引用</button>
      <p>{{ obj }}</p>
    </div>
    <script src="./vue.js"></script>
    <script>
      new Vue({
        el: '#app',
        data () {
          return {
            msg: '你好',
            obj: {
              name: 'jack',
              age: 16
            }
          }
        },
        watch: {
          // 侦听器默认情况下只能侦听到基本数据类型的改变
          msg () {
            console.log('msg被改变了')
          },
          // 因为你改obj.name，相当于obj自己没变过
          obj () {
            console.log('obj改变了')
          }
        }
      })
    </script>
  </body>
</html>
